package com.example.config;

import com.example.entity.Person;
import com.example.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;

@Configuration
@ComponentScan(value = "com.example")
public class SpringConfig {

    @Bean(value = "person1")
    @Lazy
    public Person person() {
        System.out.println("person1 lazy create");
        return new Person(12,"xiaoyu");
    }

    @Bean
    public Person person2() {
        System.out.println("person2 create");
        return new Person(12,"jingjing");
    }

    @Bean
    @Scope(value = "prototype")
    public User user() {
        System.out.println("user create!");
        return new User();
    }



}



